package SpLib.Com
{
	public function atoi(str:String):int
	{
		if(str.length==0) return 0;
		
		var f:Boolean = false;
		if(str.charAt(0)=="-")
		{
			f = true;
			str = str.substr(1);
		}
		
		var result:int = 0;
		var n:int;
		var i:int;
		for(i=0;i<str.length;i++)
		{
			n = str.charCodeAt(i) - 0x30;
			result = result*10 + n;
		}
			
		return f?-result:result;
	}	
}